package com.in.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.in.dto.DictDto;
import com.in.mapper.InDictMapper;
import com.in.service.InDictService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description InDictServiceImpl
 * @Author liulianjia
 * @Date 2025/6/12
 */
@Service
public class InDictServiceImpl implements InDictService {

    @Autowired
    private InDictMapper inDictMapper;

    @Override
    public List<DictDto> list(DictDto dto) {
        QueryWrapper<DictDto> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(dto.getDictName()), "a.dict_name", dto.getDictName())
                .eq(StringUtils.isNotBlank(dto.getDictCode()), "a.dict_code", dto.getDictCode())
                .like(StringUtils.isNotBlank(dto.getDictDesc()), "b.dict_desc", dto.getDictDesc())
                .orderByAsc("a.id, b.id");
        return inDictMapper.list(wrapper);
    }
}
